package br.com.guiav6.sisguia.utils;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import br.com.guiav6.sisguia.entity.TipoServico;

public class TipoServicoDataModel extends ListDataModel<TipoServico> implements SelectableDataModel<TipoServico> {
	
	public TipoServicoDataModel() {
	}

	public TipoServicoDataModel(List<TipoServico> list) {
		super(list);
	}

	@Override
	public Object getRowKey(TipoServico tipoServico) {
		return tipoServico.getId();
	}

	@SuppressWarnings("unchecked")
	@Override
	public TipoServico getRowData(String rowKey) {
		List<TipoServico> servicos = (List<TipoServico>) getWrappedData();
		
		for(TipoServico servico : servicos){
			if(servico.getId().longValue() == Long.parseLong(rowKey))
				return servico;
		}
		
		return null;
	}

}